package com.css.crm.vo;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "customer-email")
public class CustomerEmailVo extends AuditTrailVo {

	/** CUST_EMAIL_ID **/
	private Long custEmailId;
	/** CUST_ID **/
	private String custId;
	/** TYPE_CDE **/
	private String typeCde;
	/** EMAIL **/
	private String email;

	@XmlElement
	public String getCustId() {
		return custId;
	}

	public void setCustId(String custId) {
		this.custId = custId;
	}

	@XmlElement
	public String getTypeCde() {
		return typeCde;
	}

	public void setTypeCde(String typeCde) {
		this.typeCde = typeCde;
	}

	@XmlElement
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@XmlElement
	public Long getCustEmailId() {
		return custEmailId;
	}

	public void setCustEmailId(Long custEmailId) {
		this.custEmailId = custEmailId;
	}

	@Override
	public int compareTo(AuditTrailVo o) {
		CustomerEmailVo vo = (CustomerEmailVo) o;
		if(vo == null){
			//if not set original data, default set to modified.
			return 1;
		}
		
		String custId = this.getCustId() == null ? "" : this.getCustId();
		String typeCode = this.getTypeCde() == null ? "" : this.getTypeCde();
		String email = this.getEmail() == null ? "" : this.getEmail();
		
		String custIdCompareTo = vo.getCustId() == null ? "" : vo.getCustId();
		String typeCodeCompareTo = vo.getTypeCde() == null ? "" : vo.getTypeCde();
		String emailCompareTo = vo.getEmail() == null ? "" : vo.getEmail();


		// check if have any field be modified
		int result = 0;
		if (!custId.equals(custIdCompareTo)) {
			result = 1;
		}
		if (!typeCode.equals(typeCodeCompareTo)) {
			result = 1;
		}
		if (!email.equals(emailCompareTo)) {
			result = 1;
		}
		return result;
	}
		
}
